package com.web.kftsdk.bean;

import com.web.kftsdk.api.KftPayConfigStorage;
import com.web.kftsdk.common.bean.TransactionType;
import com.web.kftsdk.entity.BaseReq;


/**
 * 快付通交易类型
 * @author egan
 *
 * email egzosn@gmail.com
 * date 2016/10/19 22:58
 */
public enum KftTransactionType implements TransactionType {
    /**
     * 二级商户入驻
     * 用于商户自行报备二级商户。包括商户自行发展的下级商户的报备，也包括商户下的代理商报备。本接口统称二级商户。
     此接口支持幂等操作，如果商户自行报备二级商户已经存在，即根据字段merchantId、secMercId查询已经存在，则返回已经存在的商户号。若需更新商户信息，请调用商户信息更新接口。
     */
    AMP_SECMERCHANT_ADD("amp_secmerchant_add") {
        @Override
        public void setAttribute(BaseReq baseReq, KftPayConfigStorage kftPayConfigStorage) {
           baseReq.setCharset(kftPayConfigStorage.getInputCharset());
           baseReq.setVersion(kftPayConfigStorage.getVersion());
           baseReq.setService(KftTransactionType.AMP_SECMERCHANT_ADD.getMethod());
           baseReq.setLanguage(kftPayConfigStorage.getLanguage());
        }
    },
    /**
     * 二级商户信息更新
     * 用于更新商户信息。如果商户尚未报备，请调用“商户报备”接口。证件扫描件路径，证件扫描件文件签名，企业证件信息，个人证件信息，清算银行账号，开通的产品及费率等字段无更新是，请传空值。
     */
    AMP_SECMERCHANT_UPDDATE("amp_secmerchant_update"){
        @Override
        public void setAttribute(BaseReq baseReq, KftPayConfigStorage kftPayConfigStorage) {
            baseReq.setCharset(kftPayConfigStorage.getInputCharset());
            baseReq.setVersion(kftPayConfigStorage.getVersion());
            baseReq.setService(KftTransactionType.AMP_SECMERCHANT_UPDDATE.getMethod());
            baseReq.setLanguage(kftPayConfigStorage.getLanguage());
        }
    },
    /**
     * 二级商户信息查询
     * 用于查询二级商户的信息。
     不提供证件下载功能。
     */
    AMP_SECMERCHANT_QUERY("amp_secmerchant_query"){
        @Override
        public void setAttribute(BaseReq baseReq, KftPayConfigStorage kftPayConfigStorage) {
            baseReq.setCharset(kftPayConfigStorage.getInputCharset());
            baseReq.setVersion(kftPayConfigStorage.getVersion());
            baseReq.setService(KftTransactionType.AMP_SECMERCHANT_QUERY.getMethod());
            baseReq.setLanguage(kftPayConfigStorage.getLanguage());
        }
    },
    /**
     * 被动扫码支付
     * 用户打开微信、支付宝等客户端的刷卡界面，商户扫码后提交完成支付。
     */
    KPP_BDSM_PAY("kpp_bdsm_pay"){
        @Override
        public void setAttribute(BaseReq baseReq, KftPayConfigStorage kftPayConfigStorage) {
            baseReq.setCharset(kftPayConfigStorage.getInputCharset());
            baseReq.setVersion(kftPayConfigStorage.getVersion());
            baseReq.setService(KftTransactionType.KPP_BDSM_PAY.getMethod());
            baseReq.setLanguage(kftPayConfigStorage.getLanguage());
        }
    },
    /**
     * 主动扫码支付
     * 用户使用微信、支付宝等客户端的“扫一扫”，扫码商户二维码后完成支付。
     */
    KPP_ZDSM_PAY("kpp_zdsm_pay"){
        @Override
        public void setAttribute(BaseReq baseReq, KftPayConfigStorage kftPayConfigStorage) {
            baseReq.setCharset(kftPayConfigStorage.getInputCharset());
            baseReq.setVersion(kftPayConfigStorage.getVersion());
            baseReq.setService(KftTransactionType.KPP_ZDSM_PAY.getMethod());
            baseReq.setLanguage(kftPayConfigStorage.getLanguage());
        }
    },
    /**
     * APP支付
     */
    KPP_APP_PAY("kpp_app_pay"){
        @Override
        public void setAttribute(BaseReq baseReq, KftPayConfigStorage kftPayConfigStorage) {
            baseReq.setCharset(kftPayConfigStorage.getInputCharset());
            baseReq.setVersion(kftPayConfigStorage.getVersion());
            baseReq.setService(KftTransactionType.KPP_APP_PAY.getMethod());
            baseReq.setLanguage(kftPayConfigStorage.getLanguage());
        }
    },
    /**
     * 	公众号/生活号（原支付宝服务窗）支付
     */
    KPP_PA_PAY("kpp_pa_pay"){
        @Override
        public void setAttribute(BaseReq baseReq, KftPayConfigStorage kftPayConfigStorage) {
            baseReq.setCharset(kftPayConfigStorage.getInputCharset());
            baseReq.setVersion(kftPayConfigStorage.getVersion());
            baseReq.setService(KftTransactionType.KPP_PA_PAY.getMethod());
            baseReq.setLanguage(kftPayConfigStorage.getLanguage());
        }
    },
    /**
     * 公众号/生活号（原支付宝服务窗）预支付下单
     */
    KPP_PA_PREPAY("kpp_pa_prepay"){
        @Override
        public void setAttribute(BaseReq baseReq, KftPayConfigStorage kftPayConfigStorage) {
            baseReq.setCharset(kftPayConfigStorage.getInputCharset());
            baseReq.setVersion(kftPayConfigStorage.getVersion());
            baseReq.setService(KftTransactionType.KPP_PA_PREPAY.getMethod());
            baseReq.setLanguage(kftPayConfigStorage.getLanguage());
        }
    },
    /**
     * H5支付
     */
    KPP_H5_PAY("kpp_h5_pay"){
        @Override
        public void setAttribute(BaseReq baseReq, KftPayConfigStorage kftPayConfigStorage) {
            baseReq.setCharset(kftPayConfigStorage.getInputCharset());
            baseReq.setVersion(kftPayConfigStorage.getVersion());
            baseReq.setService(KftTransactionType.KPP_H5_PAY.getMethod());
            baseReq.setLanguage(kftPayConfigStorage.getLanguage());
        }
    },
    /**
     * 	短信快捷收款申请
     * 	短信快捷支付指用户购买商品时，提供银行卡卡号、户名、手机号码等信息，系统验证手机号码正确性后，发送手机验证码到用户手机，用户输入正确的验证码后，完成支付。
     此接口用于为商户提供短信快捷收款申请，并下发短信验证码到用户手机
     */
    KPP_SMS_COLLECT("kpp_sms_collect"){
        @Override
        public void setAttribute(BaseReq baseReq, KftPayConfigStorage kftPayConfigStorage) {
            baseReq.setCharset(kftPayConfigStorage.getInputCharset());
            baseReq.setVersion(kftPayConfigStorage.getVersion());
            baseReq.setService(KftTransactionType.KPP_SMS_COLLECT.getMethod());
            baseReq.setLanguage(kftPayConfigStorage.getLanguage());
        }
    },
    /**
     * 短信快捷收款确认
     */
    KPP_SMS_PAY("kpp_sms_pay"){
        @Override
        public void setAttribute(BaseReq baseReq, KftPayConfigStorage kftPayConfigStorage) {
            baseReq.setCharset(kftPayConfigStorage.getInputCharset());
            baseReq.setVersion(kftPayConfigStorage.getVersion());
            baseReq.setService(KftTransactionType.KPP_SMS_PAY.getMethod());
            baseReq.setLanguage(kftPayConfigStorage.getLanguage());
        }
    },
    /**
     * 网银支付
     */
    UNION("union"){
        @Override
        public void setAttribute(BaseReq baseReq, KftPayConfigStorage kftPayConfigStorage) {
        }
    },
    /**
     * 申请退款
     */
    KPP_REFUND("kpp_refund"){
        @Override
        public void setAttribute(BaseReq baseReq, KftPayConfigStorage kftPayConfigStorage) {
            baseReq.setCharset(kftPayConfigStorage.getInputCharset());
            baseReq.setVersion(kftPayConfigStorage.getVersion());
            baseReq.setService(KftTransactionType.KPP_REFUND.getMethod());
            baseReq.setLanguage(kftPayConfigStorage.getLanguage());
        }
    },
    /**
     * 交易查询
     */
    KPP_TRADE_RECORD_QUERY("kpp_trade_record_query"){
        @Override
        public void setAttribute(BaseReq baseReq, KftPayConfigStorage kftPayConfigStorage) {
            baseReq.setCharset(kftPayConfigStorage.getInputCharset());
            baseReq.setVersion(kftPayConfigStorage.getVersion());
            baseReq.setService(KftTransactionType.KPP_TRADE_RECORD_QUERY.getMethod());
            baseReq.setLanguage(kftPayConfigStorage.getLanguage());
        }
    },
    /**
     * 下载对账文件
     */
    KPP_RECON_RESULT_QUERY("kpp_recon_result_query"){
        @Override
        public void setAttribute(BaseReq baseReq, KftPayConfigStorage kftPayConfigStorage) {
            baseReq.setCharset(kftPayConfigStorage.getInputCharset());
            baseReq.setVersion(kftPayConfigStorage.getVersion());
            baseReq.setService(KftTransactionType.KPP_RECON_RESULT_QUERY.getMethod());
            baseReq.setLanguage(kftPayConfigStorage.getLanguage());
        }
    },
    /**
     *担保交易确认
     */
    KPP_GUAR_TRADE_CONFIRM("kpp_guar_trade_confirm"){
        @Override
        public void setAttribute(BaseReq baseReq, KftPayConfigStorage kftPayConfigStorage) {
            baseReq.setCharset(kftPayConfigStorage.getInputCharset());
            baseReq.setVersion(kftPayConfigStorage.getVersion());
            baseReq.setService(KftTransactionType.KPP_GUAR_TRADE_CONFIRM.getMethod());
            baseReq.setLanguage(kftPayConfigStorage.getLanguage());
        }
    },
    /**
     *担保交易取消
     */
    KPP_GUAR_TRADE_CANCEL("kpp_guar_trade_cancel"){
        @Override
        public void setAttribute(BaseReq baseReq, KftPayConfigStorage kftPayConfigStorage) {
            baseReq.setCharset(kftPayConfigStorage.getInputCharset());
            baseReq.setVersion(kftPayConfigStorage.getVersion());
            baseReq.setService(KftTransactionType.KPP_GUAR_TRADE_CANCEL.getMethod());
            baseReq.setLanguage(kftPayConfigStorage.getLanguage());
        }
    },
    /**
     * 退款撤销接口
     */
    KPP_REFUND_CANCEL("kpp_refund_cancel"){
        @Override
        public void setAttribute(BaseReq baseReq, KftPayConfigStorage kftPayConfigStorage) {
            baseReq.setCharset(kftPayConfigStorage.getInputCharset());
            baseReq.setVersion(kftPayConfigStorage.getVersion());
            baseReq.setService(KftTransactionType.KPP_REFUND_CANCEL.getMethod());
            baseReq.setLanguage(kftPayConfigStorage.getLanguage());
        }
    },
    ;

    KftTransactionType(String method) {
        this.method = method;
    }

    private String method;

    @Override
    public String getType() {
        return this.name();
    }
    @Override
    public String getMethod() {
        return this.method;
    }
    public  void setAttribute(BaseReq baseReq, KftPayConfigStorage kftPayConfigStorage){

    }
}
